
import XlsxData from "./XlsxData";
import { XlsxType } from "../tools/Define";
import StringHelper from "../tools/StringHelper";
export default class XlsxDataManager  {

    private dataMap = {};

    constructor(){

    }

    addFile(fileName:string,res: cc.JsonAsset){
        if(!res){
            cc.log(" init file res is null")
            return;
        }
        if(res.json.type == XlsxType.TEMPLATE){
            let room = res.json.data;
            for (const key in room) {
                this.dataMap[key] = new XlsxData(room[key]);
            }
        }else{
            let key = StringHelper.laststring(fileName,'/')
            this.dataMap[key] = new XlsxData(res.json);
        }
       
    }

    get(fileName:string):XlsxData{
        let key = StringHelper.laststring(fileName,'/')
        let data = this.dataMap[key];
        if(!data){
            return null;
        }
        return data;
    }

    clear(){
        this.dataMap = {};
    }

}
